/*
 * $Id: queue_test.c 26 2007-06-21 07:12:15Z kf701.ye $
 */

#include "kf701.h"

int main()
{
	queue_t *my_queue = data_queue_new();

	char *buffer, *p;
	int i = 5;
	while( i-- )
	{
		buffer = malloc( 128 );
		sprintf(buffer, "data-%d", i+1);
		data_queue_push_head(my_queue, buffer);
	}
	printf("queue length now = %d\n", data_queue_length(my_queue));

	/* peek */
	p = (char*)data_queue_peek_nth(my_queue, 4);
	printf("peek 4th data = %s\n", p);
	printf("queue length now = %d\n", data_queue_length(my_queue));

	/* pop */
	p = data_queue_pop_tail(my_queue);
	if( NULL == p )
	{
		printf("pop err\n");
	}
	printf("pop tail data = %s\n", p);
	free( p );
	printf("queue length now = %d\n", data_queue_length(my_queue));

	return 0;
}
